import 'package:easy_chat_app/commons/utils/RouteUtils.dart';
import 'package:easy_chat_app/commons/utils/TokenUtils.dart';
import 'package:easy_chat_app/commons/widget/ConfirmDialog.dart';
import 'package:easy_chat_app/mobile/constants/MobileAppGlobalConstants.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';

class MobileUserSettingPage extends StatefulWidget {
  const MobileUserSettingPage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _MobileUserSettingPage();
  }
}

class _MobileUserSettingPage extends State<MobileUserSettingPage> {
  Logger logger = Logger();

  @override
  Widget build(BuildContext context) {
    Color backgroundColor = const Color.fromRGBO(237, 237, 237, 1);
    return Scaffold(
        appBar: AppBar(
          title: const Text("设置"),
          centerTitle: true,
          surfaceTintColor: MobileAppGlobalConstants.appBarSurfaceTintColor,
          backgroundColor: MobileAppGlobalConstants.appBarBackgroundColor,
        ),
        body: Container(
          color: backgroundColor,
          child: Column(
            children: [
              const SizedBox(
                height: 10,
                width: double.infinity,
              ),
              GestureDetector(
                onTap: () async {
                  var result = await ConfirmDialog.show(context,
                      content: const Text("确定要退出登录么?"));
                  if (result) {
                    await TokenUtils.logout();
                    RouteUtils.route2MobileLoginPageAndCleanStack();
                  }
                },
                child: Container(
                  height: 55,
                  width: double.infinity,
                  color: Colors.white,
                  alignment: Alignment.center,
                  child: const Text(
                    "退出登录",
                    style: TextStyle(color: Colors.black, fontSize: 16),
                  ),
                ),
              )
            ],
          ),
        ));
  }
}
